import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, OneToMany, ManyToOne } from 'typeorm';

@Entity('menu')
export class MenuEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '父级id' })
  parentId: number;

  @Column({ comment: '路由路径' })
  routePath: string;

  @Column({ comment: '路由名称' })
  routeName: string;

  @Column({ comment: '路由组件路径' })
  component: string;

  @Column({ comment: '路由重定向' })
  redirect: string;

  @Column({ comment: '菜单类型' })
  type: number;

  @Column({ comment: '菜单名称' })
  name: string;

  @Column({ comment: '路由图标' })
  icon: string;

  @Column({ comment: '路由是否隐藏' })
  visible: number;

  @Column({ comment: '路由缓存' })
  keepAlive: number;

  @Column({ comment: '路由排序' })
  sort: number;

  @Column({ comment: '权限标识' })
  perm: string;

  // 递归嵌套子菜单
  // @OneToMany(() => MenuEntity, menu => menu.parent)
  // children?: MenuEntity[];

  // @ManyToOne(() => MenuEntity, menu => menu.children)
  // parent?: MenuEntity;
}
